<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%><%@ taglib prefix="c"
	uri="http://java.sun.com/jsp/jstl/core"%><%@ taglib
	uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台首页</title>
<link href="../css/style.css" rel="stylesheet" type="text/css">
<script src="../js/jquery.min.js"></script>
<script>
	function del(uid) {
		if(${sessionScope.user.id} - uid == 0 ){
			$("#msg_e").html('你不能把自己给删了...');
			var t1 = window.setTimeout(autorun,2000); 
			return false;
		}else{
			$("#msg_e").html('');
		}
		$.post("./delUser", {
			id : uid			
		}, function(data) {
			if (data.status  == 200) {
				$("#msg_e").html(data.msg);
				document.getElementById(uid).style.display = "none";
				var t1 = window.setTimeout(autorun,2000); 
				return false;
			} else {
				$("#msg_y").html('删除失败,发生未知错误...');
			}
			if(data.status == 400){
				$("#msg_e").html(data.msg);
				return false;
			}else{
				$("#msg_e").html('');
			}
			$("#msg_e").html(data.msg);
		});
		return false;
	}
	
	function autorun(){
		$("#msg_e").html('');
	}
</script>
</head>


<body>
	<center>
		<table width="650" cellspacing="0" cellpadding="0" border="0"
			height="300">
			<tbody>
				<tr>
					<td align="center">用户id</td>
					<td>用户名</td>
					<td>操作</td>
				</tr>
				<c:if
					test="${(empty requestScope.ulist) && (empty requestScope.cuser)}">
					<tr id="">
						<td align="center" colspan="3">ID不存在</td>
						<td></td>
					</tr>
				</c:if>
				<c:if test="${!empty requestScope.cuser}">
					<tr id="${cuser.id}">
						<td align="center">${cuser.id}</td>
						<td>${cuser.user_name}</td>
						<td><a href="userUpdate?id=${cuser.id}">修改</a>&nbsp;&nbsp;
						<c:if test="${sessionScope.user.user_type == 49}">
							<a onClick="">删除</a>
						</c:if>
						</td>
					</tr>
				</c:if>
				<c:if test="${!empty requestScope.ulist }">
					<c:forEach items="${requestScope.ulist}" var="temp">
						<tr id="${temp.id}">
							<td align="center">${temp.id}</td>
							<td>${temp.user_name}</td>
							<td><a href="userUpdate?id=${temp.id}">修改</a>|<a
								onClick="del(${temp.id})">删除</a></td>
						</tr>
					</c:forEach>
				</c:if>

				<c:if test="${(!empty requestScope.ulist)}">
					<tr>
						<td align="center" colspan="3">
						<c:if test="${pageNo != 1 }">
							<a href="userList?pageNo=${pageNo -1}">上一页&nbsp;&nbsp;</a>
						</c:if>
						<c:if test="${pageNo != count }">
							<a href="userList?pageNo=${pageNo+1}">下一页</a>
						</c:if>
						</td>
					</tr>
				</c:if>
				<tr><td colspan="3" align="center"><span style="color: red" id = "msg_e"></span></td></tr>
			</tbody>
		</table>
	</center>
</body>
</html>